import request from '@/utils/request'

export function login(loginName, password) {
  return request({
    url: 'plm-sys/sys/login',
    method: 'post',
    data: {
      loginName,
      password
    }
  })
}

export function resetPwd(email) {
  return request({
    url: 'plm-sys/sys/email/resetPass?email=' + email,
    method: 'post'
  })
}

export function codeVerify(info) {
  return request({
    url: 'plm-sys/sys/validated',
    method: 'post',
    data: {
      code: info.code,
      value: info.email
    }
  })
}

export function updatePwd(info) {
  return request({
    url: 'plm-sys/sys/updatePwd',
    method: 'post',
    data: {
      email: info.email,
      loginName: info.loginName,
      pwd: info.pwd
    }
  })
}

export function getInfo() {
  return new Promise((resolve, reject) => {
    resolve({
      dataScopes: [],
      roles: ['admin'],
      user: { createBy: null, updatedBy: 'admin', username: 'admin' }
    })
  })
}

export function logout() {
  return request({
    url: '/plm-sys/sys/loginout',
    method: 'post'
  })
}
